from django.db import models

# Create your models here.
class CourseInfo(models.Model):
    """创建课程模型类"""
    ctitle = models.CharField(max_length=20, verbose_name='课程标题')
    cpub_date = models.DateField(verbose_name='发布日期')
    cread = models.IntegerField(default=0, verbose_name='观看量')
    ccomment = models.IntegerField(default=0, verbose_name='评论量')
    is_delete = models.BooleanField(default=False, verbose_name='删除标记')

    class Meta:
        db_table = 'tb_courses'
        verbose_name = '课程'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.ctitle


class VedioInfo(models.Model):
    """创建视频模型类"""
    VTYPE_CHOICES = (
        (0, '精品'),
        (1, '产品'),
        (2, '研发'),
        (3, '测试'),
        (4, '运维'),
    )
    vname = models.CharField(max_length=20, verbose_name='视频名称')
    vtype = models.SmallIntegerField(choices=VTYPE_CHOICES, default=0, verbose_name='类型')
    vcomment = models.CharField(max_length=200, null=True, verbose_name='备注')
    is_delete = models.BooleanField(default=False, verbose_name='删除标记')
    vcourse = models.ForeignKey('CourseInfo', on_delete=models.CASCADE, verbose_name='所属课程')

    class Meta:
        db_table = 'tb_vedios'
        verbose_name = '视频'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.vname
